'use strict';

module.exports = app => {
  const { Sequelize } = app;

  const GoodsPrizes = app.model.define('GoodsPrizes', {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: Sequelize.INTEGER
    },
    title: {
      allowNull: false,
      type: Sequelize.STRING(255)
    },
    cover: {
      allowNull: false,
      type: Sequelize.STRING(255)
    },
    number: {
      allowNull: false,
      type: Sequelize.INTEGER(3)
    },
    goodsId: {
      type: Sequelize.INTEGER,
      allowNull: false,
      onDelete: 'CASCADE',
      onUpdate: 'CASCADE',
      references: {
        model: 'Goods',
        key: 'id'
      }
    },
  }, {
    timestamps: false,
    charset: 'utf8mb4',
    collate: 'utf8mb4_general_ci',
    comment: '商品奖品表'
  });

  return GoodsPrizes;

};